<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <link rel="icon" href="../dist/img/favicon-32x32.png" sizes="32x32" type="image/png">
  <link rel="icon" href="../dist/img/favicon-16x16.png" sizes="16x16" type="image/png">
  <meta name="keywords" content="响应式后台模板,开源免费后台模板,Bootstrap5后台管理系统模板">
  <meta name="description" content="bootstrap-admin基于bootstrap5的免费开源的响应式后台管理模板">
  <meta name="author" content="ajiho">
  <link rel="stylesheet" href="../lib/bootstrap-icons/font/bootstrap-icons.min.css">
  <link rel="stylesheet" href="../lib/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="../lib/bootstrap-table/dist/bootstrap-table.min.css">
  <link rel="stylesheet" href="../lib/@eonasdan/tempus-dominus/dist/css/tempus-dominus.min.css"/>
  <link rel="stylesheet" href="../dist/css/bootstrap-admin.min.css">
  <title>学科列表</title>
</head>
<body class="bg-body-tertiary py-3">
<div class="container-fluid">
  <div class="card border-0 shadow-sm">
    <div class="card-header bg-body py-3">
      <form class="row row-cols-sm-auto g-3 align-items-center">
        <div class="col-12">
          <div class="row">
            <label for="name" class="col-sm-auto col-form-label">角色名称</label>
            <div class="col">
              <input type="text" class="form-control" id="name" name="name" placeholder="请输入角色名称">
            </div>
          </div>
        </div>
        <div class="col-12 gap-2">
          <button type="button" class="btn btn-light bsa-querySearch-btn">
            <i class="bi bi-search"></i>搜索
          </button>
          <button type="button" class="btn btn-light bsa-reset-btn">
            <i class="bi bi-arrow-clockwise"></i>重置
          </button>
        </div>
      </form>
    </div>
    <div class="card-body">
      <table id="table"></table>
    </div>
  </div>
</div>
<!--回到顶部开始-->
<a href="javascript:" class="bsa-back-to-top"><i class='bi bi-arrow-up-short'></i></a>
<!--回到顶部结束-->

<script src="../lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="../lib/jquery/dist/jquery.min.js"></script>
<script src="../lib/@popperjs/core/dist/umd/popper.min.js"></script>
<script src="../lib/@eonasdan/tempus-dominus/dist/js/tempus-dominus.min.js"></script>
<script src="../lib/bootstrap-table/dist/bootstrap-table.min.js"></script>
<script src="../lib/bootstrap-table/dist/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="../dist/js/bootstrap-admin.min.js"></script>
<script src="../dist/js/app.js"></script>

<script>
    $(function () {
        $('#table').bootstrapTable({
            locale: 'zh-CN',
            url: 'http://127.0.0.1:8000/sub',
            responseHandler: function (res) {
                return res.subjects_info; 
            },
            pagination: true,
            sidePagination: 'server',
            pageNumber: 1,
            pageSize: 5,
            pageList: [5, 10, 25, 50, 100],
            uniqueId: 'subject_id',
            clickToSelect: true,
            columns: [
                {
                    title: '学科ID',
                    field: 'subject_id',
                    align: 'center',
                    sortable: true
                },
                {
                    title: '学科名称',
                    field: 'subject_name',
                    align: 'center'
                },
                {
                    title: '学科等级',
                    field: 'subject_level',
                    align: 'center'
                },
                {
                    title: '上级学科',
                    field: 'parent_subject',
                    align: 'center'
                },
                {
                    title: '学科概述',
                    field: 'subject_overview',
                    align: 'center'
                },
                {
                    title: '学科类型',
                    field: 'subject_type',
                    align: 'center'
                }
            ]
        });

        // 搜索处理
        $('.bsa-querySearch-btn').on('click', function () {
            $('#table').bootstrapTable('refresh');
            $('#table').bootstrapTable('selectPage', 1);
        });

        // 重置处理
        $('.bsa-reset-btn').on('click', function () {
            $('#name').val('');
            $('#table').bootstrapTable('refresh');
            $('#table').bootstrapTable('selectPage', 1);
        });
    });
</script>

</body>
</html>